﻿
namespace n_CondiEndIns
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;

using n_MyIns;
using n_Shape;
using n_GUIset;

//*****************************************************
//逻辑流程组件类
public class CondiEndIns: MyIns
{
	const int W = 49;
	//const int W = 70;
	
	public bool CanLinked;
	
	public MyIns InsStart;
	
	//构造函数
	public CondiEndIns(): base()
	{
		this.Width = W;
		this.Height = 20;//35;
		CanLinked = true;
	}
	
	//设置用户参数
	public void SetUserValue( string vName, string vGroupMes, int vX, int vY, int vAngle )
	{
		Name = vName;
		GroupMes = vGroupMes;
		SX = vX;
		SY = vY;
		
		Height = GUIset.ExpFont.Height + 4;
		//this.Height = 10;
	}
	
	public override void UserMouseClick( int mX, int mY )
	{
		if( InsStart is n_IfElseIns.IfElseIns ) {
			n_IfElseIns.IfElseIns t = (n_IfElseIns.IfElseIns)InsStart;
			if( t.ElseIns == null ) {
				t.EnableElse();
			}
		}
	}
	
	public override void UserMouseMove( bool isMouseOn, int mX, int mY )
	{
		
	}
	
	//组件绘制工作1
	//绘制组件的外形等,基础绘制工作
	public override void Draw1( Graphics g )
	{
		if( isNewTick != 0 ) {
			return;
		}
		//绘制组件名称
		Rectangle r = new Rectangle( SX, SY, W, this.Height );
		//g.DrawRectangle( Pens.White, r );
		GraphicsPath gp = Shape.CreateRoundedRectanglePath( r );
		
		
		if( CanLinked ) {
			
			Brush b = FlowBackColor;
			if( isNote ) {
				b = NoteColor;
			}
			
			g.FillPath( b, gp );
			//g.DrawPath( Pens.Orange, gp );
			//g.DrawString( "完成", GUIset.ExpFont, Brushes.Black, StartX + SX + 3, StartY + SY + HeadStringYOffset );
			
			if( isMouseOn && InsStart is n_IfElseIns.IfElseIns && ((n_IfElseIns.IfElseIns)InsStart).ElseIns == null ) {
				g.DrawString( n_Language.Language.AddElse, GUIset.ExpFont, FlowForeColor, SX + 3, SY + HeadStringYOffset );
			}
		}
		else {
			if( InsStart is n_EventIns.EventIns ) {
				n_EventIns.EventIns ei = (n_EventIns.EventIns)InsStart;
				if( ei.owner == null ) {
					g.FillPath( Brushes.Silver, gp );
				}
				else {
					
					Brush b = EventBackColor;
					if( isNote ) {
						b = NoteColor;
					}
					g.FillPath( b, gp );
				}
			}
			else {
				Brush b = UserBackColor;
				if( isNote ) {
					b = NoteColor;
				}
				g.FillPath( b, gp );
			}
			//g.DrawPath( Pens.Orange, gp );
			g.DrawString( n_Language.Language.End, GUIset.ExpFont, EventForeColor, SX + 3, SY + HeadStringYOffset );
		}
	}
}
}


